package com.lfl.zuul.utils;

import lombok.Data;
import org.springframework.stereotype.Component;

@Component
@Data
public class ResponseResult {
    private Integer code;

    private Object obj;

    private String msg;

    public static final Integer SUCCESS_CODE = 200;

    public static final Integer FAIL_CODE = 400;

    public ResponseResult successResult(Object result) {
        this.code = SUCCESS_CODE;
        this.obj = result;
        return new ResponseResult(this.code, this.obj);
    }

    public ResponseResult successResult() {
        return successResult("");
    }

    public ResponseResult failedResult(String msg) {
        return new ResponseResult(FAIL_CODE, "", msg);
    }

    public ResponseResult(Integer code, Object obj) {
        this.code = code;
        this.obj = obj;
    }

    public ResponseResult(Integer code, Object obj, String msg) {
        this.code = code;
        this.obj = obj;
        this.msg = msg;
    }

    public ResponseResult() {
    }
}
